home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / SYS / libs / req.doc < prev    next >
Text File  |  1996-09-26  |  60KB  |  1,642 lines

  1.  
  2.     The  req.library is a run time re-entrant library that is designed
  3. to  make  it  easier  for  programmers  to  use  powerful, easy to use
  4. requesters  for  communicating  with  users.   The  requester  library
  5. includes  such functions as a color requester, file requester, message
  6. display  requester  and many functions to make the creation of gadgets
  7. for your own custom requesters easier.
  8.  
  9.     Req.library  was  written  by  Colin  Fox (of Pyramyd Designs) and
  10. Bruce  Dawson  (of  CygnusSoft  Software).   Req.library  is  a freely
  11. distributable  library that may be used in commercial products without
  12. paying  any  royalties.  We encourage you to use the requester library
  13. in all of your programs, to make them easier to write, and to use.
  14.  
  15.     Req.library  is  not public domain.  The requester library and all
  16. documentation and example programs are all copyright 1989.
  17.  
  18.     The  requester  library must be distributed with the documentation
  19. file  (req.doc),  and  the  three  include files (req.h, reqbase.h and
  20. reqbase.i).
  21.  
  22.  
  23.  
  24.     Req.library  is  dedicated  to  the programmers who make the Amiga
  25. shine the way it was meant to.
  26.  
  27.  
  28. OverView:
  29.  
  30.     All  of  the  req.library functions that bring up requesters allow
  31. you two ways of specifying what screen you would like the requester to
  32. appear  on.  The first way is the more efficient way, because you only
  33. have  to set it up once and then it takes care of things automatially.
  34. There  is  a  field in all process structures called the pr_WindowPtr.
  35. This  pointer  is  used by DOS to decide where to put it's requesters.
  36. If  pr_WindowPtr  contains  a  zero,  requesters  go  on the workbench
  37. screen.  If it contains the address of a window, then requesters go on
  38. that  window's  screen.   If  it  contains a negative one, then no DOS
  39. requesters come up.  The req.library requesters all use this variable,
  40. if  they  are  called from a process .  However, if the pointer is -1,
  41. the req.library functions do still appear, on the workbench screen.
  42.  
  43.     The  second  way  was  put in mainly so that the requesters can be
  44. called from tasks.  Since a task does not have a process structure, it
  45. also  lacks a pr_WindowPtr.  Therefore, all of the requester functions
  46. which  can  be  used from a task (currently everything except the file
  47. requester) can be passed a window pointer, either as a parameter or as
  48. an  element in a structure.  Important:  This pointer takes precedence
  49. over  the  pr_WindowPtr  so  if  you  wish  the  requesters to use the
  50. pr_WindowPtr  you  must  zero  the window fields that the routines are
  51. expecting.   In  the case of fields in a structure this can be easy as
  52. long   as  you  make  sure  your  structure  defaults  to  being  zero
  53. everywhere.
  54.  
  55.     Setting  the  pr_WindowPtr is quite a simple matter.  All you have
  56. to do is do a FindTask((char *)0); which returns a pointer to your own
  57. task  and your own process (a task structure is the first element of a
  58. process  structure).   Then  you  simply  preserve  the  old  value of
  59. pr_WindowPtr (VERY IMPORTANT!!!) and put a window pointer into it.
  60.  
  61. eg:
  62.                 /* Find my task. */
  63.     myprocess = (struct Process *)FindTask((char *)0);
  64.     oldwindowptr = myprocess->pr_WindowPtr;
  65.     myprocess->pr_WindowPtr = window;
  66.  
  67. or:
  68.  
  69.     MOVE.L  4,A6
  70.     MOVE.L  #0,A1
  71.     SYS     FindTask    ;Find my task.
  72.     MOVE.L  D0,_myprocess
  73.     MOVE.L  D0,A0
  74.     MOVE.L  pr_WindowPtr(A0),_oldwindowptr
  75.     MOVE.L  _window,pr_WindowPtr(A0)
  76.  
  77.     Before your program exits it is VERY important that it restore the
  78. previous  value of pr_WindowPtr.  If you don't, then your program will
  79. work  in some situations, but will BLOW UP in others.  For example, if
  80. you  execute  (without  using the 'run' command) a program, which then
  81. sets  the  pr_WindowPtr  to  point at one of its windows and the exits
  82. without  restoring  it,  then  the  next time a DOS requester tries to
  83. appear...  BOOM!  The machine will probably crash as DOS tries to open
  84. a requester on a now closed screen.  Therefore, before leaving:
  85.  
  86.     myprocess->pr_WindowPtr = oldwindowptr;
  87.  
  88. or:
  89.  
  90.     MOVE.L  _myprocess,A0
  91.     MOVE.L  _oldwindowptr,pr_WindowPtr(A0)
  92.  
  93.  
  94.  
  95.     One  final  note.   The  pr_WindowPtr  field exists in the process
  96. structure.   This  means  that  a  task  does  not  have  this  field.
  97. Therefore,  if you want to call one of the requester library functions
  98. from  a  task,  you  will not be able to specify what screen you would
  99. like  the  requester  to  appear on by setting the pr_WindowPtr field.
  100. All  of  the  functions  that open requesters and can be called from a
  101. task  (the file requester/font requester is the only one that can't be
  102. called  froma task) have some other way of specifying which screen you
  103. would like them to open on.  They will have either have a field in the
  104. structure  which you must pass them or a parameter which can contain a
  105. window  pointer  to one of the windows on your custom screen.  If this
  106. pointer is non-zero then it overrides the pr_WindowPtr field.
  107.  
  108.  
  109.  
  110.  
  111.     By  opening the requester library, you not only gain access to all
  112. of  the functions documented below, but to some other goodies as well.
  113. Req.library   needs  and  therefore  opens  several  other  libraries,
  114. including  dos.library,  intuition.library,  graphics.library  and the
  115. console  device.   All  of  these  pointers  are  stored in the ReqLib
  116. structure  which  you  get a pointer to when you open the req.library.
  117. Therefore,  you  can  save  yourself  a little bit of code by grabbing
  118. these  fields  after opening the requester library.  The only thing to
  119. beware of is don't use these values after you have close the requester
  120. library,  because  at  that point there is no guarantee that they will
  121. still be valid.
  122.  
  123.     In  addition  to  these  libraries,  the Images pointer in the req
  124. library structure points to a set of ten small images (four arrows and
  125. ssix  letters)  which have are guaranteed to be in chip memory.  These
  126. can be used if your program requires this type of images.
  127.  
  128.  
  129.  
  130.  
  131.     One  thing to keep in mind when using the gadget creation routines
  132. is  that there isn't any way for us to check that you have passed us a
  133. pointer  to  the  correct size of buffer, so you _must_ make sure that
  134. you are allocating the right amount of memory.
  135.  
  136.  
  137. --------------------------------------------------------------
  138. Here's a quick list of the functions available:
  139. --------------------------------------------------------------
  140.  
  141. Center..................Center a new window over the mouse.
  142.  
  143. SetSize.................Prop gadget handling routines (32 bit)
  144. SetLocation
  145. ReadLocation
  146.  
  147. Format..................sprintf() format routine
  148.  
  149. SimpleRequest...........Starter gluecode to TextRequest- Single gadget
  150. TwoGadRequest...........Starter gluecode to TextRequest- Two gadgets
  151.  
  152. FileRequester...........FileRequester routines
  153. PurgeFiles
  154.  
  155. ColorRequester..........a colorrequester
  156.  
  157. MakeGadget..............Gadget creation routines
  158. MakeString
  159. MakeProp
  160. MakeButton
  161.  
  162. MakeScrollBar...........3   part   gadget;   2   arrows  and  a  prop.
  163.                         Horizontal or Vertical
  164.  
  165. LinkGadget..............Gadget  creation  routines that self-hook into
  166.                         the newwindow
  167. LinkStringGadget........gadget list.
  168. LinkPropGadget
  169.  
  170. DrawBox.................Draw a box (x1y1)(x2y2) in one command
  171.  
  172. GetFontHeightAndWidth...return height and width of current font
  173.  
  174. RealTimeScroll..........scroll routine used in file requester
  175.  
  176. TextRequest.............Powerful requester function
  177.  
  178. GetString...............Get a line of text from the user
  179. GetLong.................Get a signed long from the user
  180.  
  181. RawKeyToAscii...........Convert raw key to ascii
  182.  
  183. ----------------------------------------------------------------
  184.  
  185.  
  186. NAME
  187.         Center
  188.  
  189.  
  190. SYNOPSIS
  191.         Center( &nw, x, y)
  192.                  A0 D0 D1
  193.  
  194. struct NewWindow *nw;
  195. USHORT x,y;
  196.  
  197. DESCRIPTION
  198.  
  199.     Center()  is  used  to  adjust  a  NewWindow structure so that the
  200. window that it opens will appear immediately under the mouse.  The x,y
  201. values  are used to specify which part of the window you would like to
  202. appear  underneath  the mouse.  If x or y is zero, that tells Center()
  203. to  position  the  window  so  that  the  window center (in the x or y
  204. direction  respectively)  is  underneath  the  mouse.   If  x  or y is
  205. positive, that tells Center() to position the window so that the mouse
  206. is  that  many  pixels  from  the  left  or  top  edge  of  the window
  207. respectively.   If x or y is negative, that tells Center() to position
  208. the  window  structure so that the mouse appears that many pixels from
  209. the right or bottom edge of the window respectively (ie; x = -10 tells
  210. Center  to  position  the  mouse  ten  pixels to the left of the right
  211. edge).
  212.  
  213.     If it is impossible to position the window exactly where requested
  214. (if  the  mouse  pointer  is too close to the edge of the screen) then
  215. this  routine  will  position  the  window as close as possible to the
  216. correct location.
  217.  
  218.     To  allow  this routine to work accurately it is necessary to have
  219. already initialized the new window structure to specify on what screen
  220. the  window  is  going  to  be  open.  ie; you should set the Type and
  221. Screen fields before calling Center().
  222.  
  223.     This routine disturbs no registers.
  224.  
  225. RETURNS
  226.         nothing
  227. SEE
  228.  
  229. BUGS
  230.         None known
  231.  
  232.  
  233. ;--------------------------------------------------------------------
  234.  
  235. NAME
  236.             SetSize
  237. SYNOPSIS
  238.  
  239.             SizeVal=SetSize(MaxValue,ViewSize)
  240.               D0.W              D0.L  D1.L
  241.  
  242. short   SizeVal;
  243. long    MaxValue,ViewSize;
  244.  
  245. DESCRIPTION
  246.  
  247.     This  routine is designed to correctly handle sizing a prop gadget
  248. to  a range.  The range is given in in MaxValue/ViewSize.  MaxValue is
  249. the  maximum value that this prop is supposed to be able to represent.
  250. Viewsize  is  how  large  the  display area is.  For instance, if your
  251. maximum  value  was 200 (files, for example), and your viewsize was 15
  252. (lines of text), then you would call this as so:
  253.  
  254.         SizeVal=SetSize(200,15);
  255.  
  256.     Then you would put SizeVal into the appropriate PropInfo structure
  257. element (in the case of the file requester, that would be VertBody).
  258.  
  259. RETURNS
  260.         The  16 bit value to be put into the PropInfo structure of the
  261. prop gadget.
  262.  
  263. SEE
  264.         SetLocation, ReadLocation
  265. BUGS
  266.         Bugs? what bugs?
  267.  
  268.  
  269. ;--------------------------------------------------------------------
  270.  
  271. NAME
  272.             SetLocation
  273. SYNOPSIS
  274.  
  275. NewLoc = SetLocation(MaxValue,ViewSize,Value);
  276.   D0                    D0      D1      D2
  277.  
  278. short NewLoc;
  279. long MaxValue,ViewSize,Value;
  280.  
  281. DESCRIPTION
  282.  
  283.             When you have a prop gadget that you wish to directly set,
  284. then  this  is  the  routine to use.  It allows you to pass any 32 bit
  285. value and properly set the gadget.
  286.  
  287. RETURNS
  288.  
  289.     The  return  is  the value to put into either HorizPot or VertPot,
  290. depending on what orientation you have the gadget.
  291.  
  292.  
  293. BUGS
  294.  
  295.     n/a
  296.  
  297. EXAMPLE
  298.  
  299. SEE
  300.     SetSize(),ReadLocation()
  301.  
  302. ;--------------------------------------------------------------------
  303.  
  304. NAME
  305.             ReadLocation
  306. SYNOPSIS
  307.  
  308. LocVal=ReadLocation(MaxValue,ViewSize,PotValue)
  309.   D0                  D0.L    D1.L     D2.W
  310.  
  311. long LocVal,MaxVal,ViewSize;
  312. short PotValue;
  313.  
  314.  
  315. DESCRIPTION
  316.  
  317.         If  you  prop  gadget has been moved, this is the routine that
  318. you would use to determine where it's been moved to.
  319.  
  320. RETURNS
  321.         Returns  the decoded value of the prop, as an unsigned 32 bit.
  322. This  is  the  element  number  (line  number  usually) that should be
  323. displayed on the first line of your display window.
  324.  
  325. SEE
  326.  
  327.     SetSize(), SetLocation()
  328.  
  329. BUGS
  330.     n/a
  331.  
  332. EXAMPLE
  333.  
  334. ;--------------------------------------------------------------------
  335.  
  336. NAME
  337.             Format
  338. SYNOPSIS
  339.  
  340.         Format(Buffer,string,values)
  341.                 A2      A0     A1
  342.  
  343. char *Buffer,string[];
  344. char **values;
  345.  
  346. DESCRIPTION
  347.  
  348.         This does the same thing as sprintf(), except that it isn't in
  349. the  stdio  library, and doesn't use up very much room.  This function
  350. uses  the  ROM  function  RawDoFmt to do the print() style formatting.
  351. This  routine does not allow the use of all of the '%' directives (for
  352. example,  floating  point  numbers can not be printed with this).  For
  353. full   documentation   on  what  directives  are  supported,  see  the
  354. documentation  on RawDoFmt.  This is the routine that TextRequest (and
  355. therefore   SimpleRequest   and  TwoGadRequest)  use  for  their  text
  356. formatting, so these restrictions apply to them also.
  357.  
  358.         The RawDoFmt routine also assumes that 'int's are sixteen bits
  359. long.   Therefore,  if  you  are  using a compiler with an int size of
  360. thirty-two  bits and you want to print an int or a short, you must use
  361. '%ld', rather than '%d'.
  362.  
  363. RETURNS
  364.         The number of characters in the formatted string.
  365. BUGS
  366.     none known
  367.  
  368. EXAMPLE
  369.  
  370.     Format(Buffer,"There are %d changes to the file %s.",numchanges,
  371. filename);
  372.  
  373.     Format(Buffer,"%x is a hex number, %c is a character.", num, chr);
  374.  
  375. SEE
  376.     TextRequest, SimpleRequest, TwoGadRequest.
  377.     Further  information  on printf() style formatting is available in
  378. the AutoDocs on RawDoFmt and in C manuals discussing printf().
  379.  
  380. ;--------------------------------------------------------------------
  381.  
  382.  
  383.  
  384. NAME
  385.             ColorRequester
  386. SYNOPSIS
  387.  
  388. NewColor=ColorRequester(DesiredColor);
  389.    D0                       D0
  390. long    DesiredColor;
  391.  
  392. DESCRIPTION
  393.  
  394.     This  is a full-fledged color requester.  It is intelligent enough
  395. to open with the right number of colours in the palette automatically.
  396. It  shows  you both the colour you are working with, and the numerical
  397. RGB  value  of  that  colour.   It  has  Spread,  Undo,  Ok and Cancel
  398. functions.  Planned is the addition of HSV.
  399.  
  400.     The  cursor  keys move the color-cursor around the palette, RETURN
  401. selects the current color and ESC cancels out.
  402.  
  403.     You  pass  this  routine  the  color that you would like initially
  404. highlighted  (typically  the  current drawing colour).
  405.  
  406.     The ExtendedColorRequester function has slightly more options, but
  407. is slightly more work to call.
  408.  
  409. RETURNS
  410.  
  411.     Color  number  that  the user selected, -1 if the user cancels the
  412. colour  requester.   The  changed  colours  will  be  in  the viewport
  413. structure for your screen.
  414.  
  415. SEE
  416.     ExtendedColorRequester
  417.  
  418. BUGS
  419.  
  420.     none known.
  421.  
  422. EXAMPLE
  423.  
  424.     newcolor = ColorRequester(oldcolor);
  425.  
  426. ;--------------------------------------------------------------------
  427.  
  428. NAME
  429.             ExtendedColorRequester
  430. SYNOPSIS
  431.  
  432. NewColor=ExtendedColorRequester(&(struct ExtendedColorRequester)
  433.    D0                                      A0
  434. struct ExtendedColorRequester   colorreqstruct;
  435.  
  436. DESCRIPTION
  437.     This  call  brings  up  exactly  the  same  color requester as the
  438. ColorRequester  call.  The only difference is that this routine allows
  439. you  to  specify  more  parameters.   The difference is actually quite
  440. small  right  now, because there is only one additional parameter that
  441. can  be  passed  through  this  entry  point.   This is the ecr_window
  442. parameter,  used  to  specify  what window (and hence what screen) the
  443. color 'requester' appears on.  This parameter is rarely needed because
  444. the  window  the requester opens up on can be specified by setting the
  445. pr_WindowPtr  field  in  your process structure to the address of your
  446. window  structure  (see  the  beginning of the docs for an overview on
  447. this procedure).  The only time this entry point is needed, currently,
  448. is  if you try to bring up the color requester on a custom screen from
  449. a  task,  since  a task does not have a pr_WindowPtr and can therefore
  450. not specify the window and screen.
  451.  
  452. RETURNS
  453.  
  454.     Color  number  that  the user selected, -1 if the user cancels the
  455. colour  requester.   The  changed  colours  will  be  in  the viewport
  456. structure for your screen.
  457.  
  458. SEE
  459.     ColorRequester
  460.  
  461. BUGS
  462.  
  463.     none known.
  464.  
  465. EXAMPLE
  466.  
  467.         /* This should generally be declared as a global variable */
  468.         /* so that all of it's elements get initialized to zero.  */
  469.         /* If you declare it as a local variable, be sure to zero */
  470.         /* all of the fields, even the unused ones. */
  471.     struct ExtendedColorRequester   colorstruct;
  472.  
  473.     colorstruct.defcolor = 0;
  474.     colorstruct.window = mywindow;
  475.     newcolor = ExtendedColorRequester(&colorstruct);
  476.  
  477. ;--------------------------------------------------------------------
  478.  
  479. NAME
  480.             MakeGadget
  481. SYNOPSIS
  482. MakeGadget(Buffer,String, X, Y)
  483.               A0    A1   D0 D1
  484. struct Buffer   *GadgetBlock;
  485. char            *String;
  486. long            D0,D1;
  487. DESCRIPTION
  488.  
  489.         This  routine  prepares a buffer to be a standard BOOLEAN text
  490. gadget.   This is a simple way of producing gadgets for code that must
  491. be  reentrant,  and it is more efficient than defining gadgets in data
  492. statements.    The  routine  initializes  the  gadgets  to  a  set  of
  493. 'standard' values that should cover most cases and then links the four
  494. parts of the GadgetBlock together.
  495.  
  496.     Buffer  is  a pointer to a unitialized GadgetBlock, which contains
  497. the  necessary  Gadget, Border, border pairs and IntuitText structures
  498. needed to render a boolean gadget with a border and some text.
  499.  
  500.     String  is  a  pointer  to  the text that should appear inside the
  501. gadget.   The  gadget  is  automatically  sized  to  match the strings
  502. length.
  503.  
  504.     X  and  Y are the gadgets initial position, they are simply copied
  505. into LeftEdge and TopEdge in the gadget structure.
  506.  
  507. RETURNS
  508. SEE
  509. BUGS
  510. EXAMPLE
  511.  
  512.  
  513. ;--------------------------------------------------------------------
  514.  
  515. NAME
  516.             MakeString
  517.  
  518. SYNOPSIS
  519. MakeString(Buffer,StringBuff,UndoBuff,MaxWidthBits,MaxNumChars, X, Y)
  520.              A0      A1          A2        D0          D1      D2  D3
  521.  
  522. struct Buffer   *StringBlock;
  523. char            *StringBuff;
  524. char            *UndoBuff;
  525. long            MaxWidthBits, MaxNumChars, X, Y;
  526.  
  527. DESCRIPTION
  528.  
  529.     As  with  all  of  the  MakeGadget  functions, this one prepares a
  530. buffer  to  be used as a string gadget, that may be used re-entrantly.
  531. The  buffer need not be cleared first.  This means that you may create
  532. a temporary gadget on the stack.
  533.  
  534.     The  StringBuff  is  where the body of text inside the gadget will
  535. reside.
  536.  
  537.     When   the   gadget  is  activated,  the  text  in  StringBuff  is
  538. automatically copied (by intuition) into UndoBuff.  This allows you to
  539. type  Amiga-Q  and get the old string back.  This field may be null if
  540. you wish to have no undo.
  541.  
  542.     MaxWidthBits is the width of the frame around the gadget.
  543.  
  544.     MaxNumChars  is  the maximum number of characters that you will be
  545. able  to  type  into the gadget, including the terminating zero on the
  546. string.  MAKE SURE that this number is no greater than your StringBuff
  547. size, or else you're going to be typing over memory that isn't yours.
  548.  
  549.     X,Y  are the position of the upper left hand corner of the gadget.
  550. The border is actually 2 pixels above and to the left of this corner.
  551.  
  552. RETURNS
  553.     Nothing
  554. SEE
  555.  
  556.     MakeGadget,MakeProp,MakeScrollbar,LinkGadget,LinkProp,LinkString
  557.  
  558.  
  559. ;--------------------------------------------------------------------
  560.  
  561. NAME
  562.             MakeProp
  563. SYNOPSIS
  564.  
  565. MakeProp(Buffer,Width,Height,Flags)
  566.          A0       D0   D1    D2
  567.  
  568. struct  Buffer  *PropBlock;
  569. long            Width, Height, Flags;
  570.  
  571. DESCRIPTION
  572.  
  573.     This  routine  prepares an un-initialized buffer for use as a prop
  574. gadget.
  575.  
  576.     Buffer,  on  return,  will  contain  the  gadget,  along  with the
  577. necessary PropInfo and Image structures, all linked together.
  578.  
  579.     Width is the with of the container, in pixels.
  580.     Height is the height of the container in pixels.
  581.  
  582.     The  Flags  parameter  is  where you decide if you want FREEHORIZ,
  583. FREEVERT, or both.  It is simply copied into the gadget flags field.
  584.  
  585.  
  586. RETURNS
  587.  
  588.     Nothing
  589.  
  590.  
  591. ;--------------------------------------------------------------------
  592.  
  593. NAME
  594.             DrawBox
  595. SYNOPSIS
  596.  
  597. DrawBox(rp,MinX,MinY,MaxX,MaxY)
  598.         A1  D0   D1   D2   D3
  599.  
  600. struct  RastPort        *rp;
  601. long    MinX,MinY,MaxX,MaxY;
  602.  
  603.  
  604. DESCRIPTION
  605.  
  606.         This  routine  allows you to draw a simple box in one command.
  607. It  draws  the  box  in APen color, in the current draw mode, with the
  608. current line pattern.
  609.  
  610.         (MinX,MinY)  are  the  upper  left  corner  of  the  box,  and
  611. (MaxX,MaxY) are the lower right.
  612.  
  613.         The pen is left at the upper left corner (MinX,MinY).
  614.  
  615. ;--------------------------------------------------------------------
  616.  
  617. NAME
  618.             MakeButton
  619. SYNOPSIS
  620.  
  621. MakeButton(Buffer,Image,Image2,Width,Height,Depth)
  622.              A0     A1    A2     D0    D1    D2
  623.  
  624.  
  625. struct  TwoImageGadget  *Buffer;
  626. char    *Image;     /* Pointer to the actual bitplane data */
  627. char    *Image2;    /* Pointer to the second image. */
  628. long    Width,Height,Depth;
  629.  
  630.  
  631.  
  632.  
  633. DESCRIPTION
  634.  
  635.     The  purpose  of  this  routine  is one similar to MakeGadget, but
  636. instead of using text for the button, it uses a graphic.  You supply a
  637. bitmap, and MakeButton will use it in it's rendering.
  638.  
  639.     You  may  have  either  one  or two images, the routine handles it
  640. routinely.   If you supply one image, then this sets GADGHCOMP, and if
  641. you  have two images, it sets GADGHIMAGE.  RELVERIFY is always set, so
  642. as  long  as  you  the  user  is  pressing  that gadget, the alternate
  643. highlight is shown.
  644.  
  645.     Buffer has room for two images.
  646.  
  647.     Image  is  a pointer to the actual image data, in CHIP memory, for
  648. this gadget.
  649.     Image2 is a pointer to the alternate image data.
  650.  
  651.     Width and Height make up the size of your image.
  652.  
  653.     Depth is how many bitplanes of data you've supplied.
  654.  
  655. BUGS
  656.     It's  not  really  a bug, but if your images aren't the same size,
  657. then one won't erase the other when it is drawn, so you may be showing
  658. an image with traces of the other one left there.
  659.  
  660. ;--------------------------------------------------------------------
  661.  
  662. NAME
  663.             MakeScrollBar
  664. SYNOPSIS
  665.  
  666. MakeScrollBar(Buffer,Flags,Size,X,Y)
  667.                 A0    D0    D1 D2 D3
  668.  
  669. struct ScrollBlock *Buffer;
  670. long    Flags,Size,X,Y;
  671.  
  672.  
  673. DESCRIPTION
  674.  
  675.     This is a special routine that creates a scrollbar (which consists
  676. of  a prop gadget and two arrows) and you handle it like it's a single
  677. gadget.   You  may  have  either a horizontal scrollbar, or a vertical
  678. scrollbar.   These scrollbars are very much like the ones in workbench
  679. window  borders.   These  use slightly different images on the arrows,
  680. however.
  681.  
  682.     The  way  you  determine  how  this set up and oriented is by flag
  683. combinations.   If  you wished to put a scrollbar in the bottom border
  684. of a window, then you would pass (in flags):
  685.  
  686.         Flags = (HORIZSLIDER | GRELBOTTOM | GRELWIDTH)
  687.  
  688.     If you wished it in the right border:
  689.  
  690.         Flags = (VERTSLIDER | GRELRIGHT | GRELHEIGHT)
  691.  
  692.     The  idea is to allow you to manipulate the scrollbar as though it
  693. were  a  single  gadget, not three.  If you pass confusing flags (like
  694. GRELBOTTOM|GRELHEIGHT) then it is undefined what will happen.
  695.  
  696.     If all you want is a simple scrollbar that doesn't size, then just
  697. set VERTSLIDER or HORIZSLIDER.
  698.  
  699. SEE
  700.  
  701.  
  702. ;--------------------------------------------------------------------
  703.  
  704. NAME
  705.             PurgeFiles
  706. SYNOPSIS
  707.     PurgeFiles(&FileRequesterStructure)
  708.                         A0
  709. DESCRIPTION
  710.     Clear  up  all  memory  and  file  locks  allocated  by  the  file
  711. requester.   This  routine must be called before your program exits if
  712. you  use  the  file requester with either FRQEXTSELECTM bit set or the
  713. FRQCACHINGM bit set.  The first bit is if you want the user to be able
  714. to select multiple files.  The file requester has to allocate a linked
  715. list  of  file  names which this function will purge.  The FRQCACHINGM
  716. bit  is set if you want the file requester to remember the contents of
  717. a directory between calls.
  718.  
  719.     This  routine can be called any time you want the buffers and file
  720. locks purge.
  721.  
  722. RETURNS
  723.     This routine does not return anything.
  724.  
  725. SEE
  726.     FileRequest
  727. BUGS
  728.     None known.
  729. EXAMPLE
  730.  
  731. main()
  732.     {
  733.     FileRequest(&FileRequesterStructure);
  734.  
  735.     .
  736.     .
  737.     .
  738.  
  739.     PurgeFiles(&FileRequesterStructure);
  740.     }
  741.  
  742.  
  743.  
  744. ;--------------------------------------------------------------------
  745.  
  746. NAME
  747.             GetFontHeightAndWidth
  748. SYNOPSIS
  749.  
  750. DESCRIPTION
  751.  
  752.         This allows you quick access to the font attributes set by the
  753. user  in preferences.  The font width is returned in D0 and the height
  754. is returned in D1.
  755.  
  756. RETURNS
  757. SEE
  758. BUGS
  759. EXAMPLE
  760.  
  761.  
  762.  
  763. ;--------------------------------------------------------------------
  764.  
  765. NAME
  766.             LinkGadget
  767. SYNOPSIS
  768.  
  769. LinkGadget(Buffer,String,nw, X, Y)
  770.              A0     A1   A3 D0 D1
  771.  
  772. struct  GadgetBlock *Buffer;
  773. char    *String;
  774. struct  NewWindow *nw;
  775. long    X,Y;
  776.  
  777. DESCRIPTION
  778.  
  779.     This  is  actually  a superset of the previous command MakeGadget.
  780. What  this  does  is automatically link the gadget into your NewWindow
  781. structure's gadget list.
  782.  
  783.         No registers are disturbed.
  784.  
  785. SEE
  786.     MakeGadget
  787. BUGS
  788.     n/a
  789.  
  790.  
  791.  
  792. ;--------------------------------------------------------------------
  793.  
  794. NAME
  795.             LinkStringGadget
  796. SYNOPSIS
  797. LinkStringGadget(Buffer,StringBuf,UndoBuf,nw, WidthBits,NumChars, X, Y)
  798.                    A0     A1        A2    A3     D0       D1     D2 D3
  799.  
  800. struct  StringBlock *Buffer;
  801. char    *StringBuf;
  802. char    *UndoBuf;
  803. struct  NewWindow *nw;
  804. long    WidthBits,NumChars,X,Y;
  805.  
  806. DESCRIPTION
  807.  
  808.     This  is  number 2 in the LinkGadget routines.  This one obviously
  809. links  the  string  gadget  to the window's gadget list.  In fact, the
  810. only  difference  between  this  and  the  MakeString  routine  is the
  811. addition of the NewWindow pointer.
  812.  
  813. SEE
  814.     MakeStringGadget
  815.  
  816.  
  817. ;--------------------------------------------------------------------
  818.  
  819. NAME
  820.             LinkPropGadget
  821. SYNOPSIS
  822.  
  823. LinkPropGadget(Buffer,nw, Width, Height, Flags, LeftEdge, TopEdge)
  824.                  A0   A3    D0     D1     D2       D3       D4
  825.  
  826. struct  PropBlock   *Buffer;
  827. struct  NewWindow   *nw
  828. long    Width,Height,Flags,LeftEdge,TopEdge;
  829.  
  830. DESCRIPTION
  831.  
  832.     Here  we  have a superset for MakeProp.  It works exactly the same
  833. as  MakeProp,  except  that  it attaches the gadget to the head of the
  834. list in the window.
  835.  
  836. SEE
  837.     MakeProp
  838.  
  839.  
  840. ;--------------------------------------------------------------------
  841.  
  842. FileRequester
  843.  
  844. NAME
  845.     FileRequester  - bring up a file/font requester.
  846.  
  847. SYNOPSIS
  848.     success = FileRequester(&FileRequesterStructure)
  849.       D0                              A0
  850.  
  851. FUNCTION
  852.     Bring  up  a  fully  intuitionized file/font requester (actually a
  853. window) and let the user select a file/font.
  854.  
  855. INPUTS
  856.     &FileRequesterStructure  -  pointer  to  an  initialized  (can  be
  857. initialized mostly to zeroes) file requester structure.
  858.  
  859. RESULT
  860.     Returns  TRUE  or FALSE to say whether the user selected a file or
  861. not.   The  file name(s) or font selected are then found by looking at
  862. the file requester structure whose address was passed.
  863.  
  864.     For  ideas  on  customizing the file requester for your particular
  865. system  (thus  overriding the defaults used by programmers who use the
  866. file requester) see the customizefile.asm file.
  867.  
  868. BUGS
  869.     Problem  with  an  Intuition bug that messes up the current active
  870. window  if  a  window  closes  when one of its string gadgets is still
  871. active.   This bug show up if you run the file requester straight from
  872. a CLI window and then exit it with Amiga-L.
  873.     I have heard that it resets some window flags when run on a custom
  874. screen,  but I believe this is a feature of Intuition, not of the file
  875. requester.
  876.  
  877. SEE ALSO
  878.     PurgeFiles
  879.  
  880.  
  881.     The  file  requester  in  the  requester  library  allows to put a
  882. powerful  and  easy  to  use  file requester into your programs with a
  883. minimum of work and at a very small expense in program size.  The file
  884. requester  was  designed  to be as easy as possible to call, while not
  885. sacrificing power.
  886.  
  887.     To  get  the  file  requester to come up all you need to do (after
  888. opening  the  requester  library of course) is to allocate space for a
  889. FileRequester  structure  and  then  call  the file requester with the
  890. address  of  this structure, with all fields initialized to zero, like
  891. this:
  892.  
  893. struct FileRequester MyFileReqStruct;
  894.  
  895. success = FileRequester(&MyFileReqStruct);
  896.  
  897.     The function will return either one or zero for success or failure
  898. respectively.
  899.  
  900.     You can specify what screen the file requester should appear on in
  901. one  of  two  ways.  If you want it to appear on a custom screen, then
  902. the  best  way  is  to  set  the  pr_WindowPtr  field  in your process
  903. structure  to  point at one of the windows on your screen (this should
  904. be  done anyway, so that DOS requesters appear on your custom screen).
  905. This  field  is looked at by all functions in the requester library so
  906. this  way  is the simplest method.  The other way, which overrides the
  907. pr_WindowPtr  field  is to initialize the frq_Window field to point at
  908. one of your windows.  If this field is non-zero, it is used instead of
  909. the pr_WindowPtr field of your process structure.  Important note:  It
  910. is  VERY  important  that you reset the pr_WindowPtr field back to its
  911. original  value  before  your  program  exits.  If you don't, the next
  912. program run may try to open a requester window on a now closed screen.
  913.  
  914.     The  file  requester  was  carefully  designed so that it could be
  915. called  without  having  to  initialize  very  many  fields.   This is
  916. demonstrated  by  seeing  that  it  is  possible  to  call  it without
  917. initializing any fields.  There are a few fields that are necessary to
  918. actually  get  any  use  out  of  it,  but  very  view.  Those few are
  919. documented in the following paragraph.
  920.  
  921.     Although  you can bring the file requester up without initializing
  922. any  fields there are a couple of fields that you will definitely want
  923. to  initialize.   The  file  requester isn't much use unless you get a
  924. file  name back out of it, and for this you need to initialize the Dir
  925. and  File  fields.   These two fields should point to character arrays
  926. that  are,  respectively,  DSIZE+1  and FCHARS+1 bytes long.  When the
  927. file  requester  is first run the file requester looks in these arrays
  928. for  the  default  directory  and file names and if the user selects a
  929. file  name  the  directory  and  file  name are copied back into these
  930. arrays.  You will probably want to initialize the Title field with the
  931. message  that you want to have appear at the top of the file requester
  932. window.
  933.  
  934.     If  you initialize the PathName field (it should point an array of
  935. at least DSIZE+FCHARS+2 characters) then when the user selects a file,
  936. the complete path name will be put into this array.
  937.  
  938.     The Window field is used to specify what window the file requester
  939. is associated with.  This is used to get the file requester to show up
  940. on  a  custom  screen.   Generally  this  field should be unnecessary.
  941. There  is a variable provided in a process structure which is used for
  942. this purpose.  Any program that opens a custom screen and uses any DOS
  943. functions  should set the pr_Window pointer in their process structure
  944. to  a  pointer  to their window so that DOS requesters will show up on
  945. their  custom  screen.   If  you do this, then the file requester will
  946. also  show  up  on  your custom screen.  If you are not using a custom
  947. screen  then you don't need to set the pr_Window pointer or the Window
  948. field  in  the  file  requester  structure.   Note:  If you do set the
  949. pr_Window  structure in the process structure, be sure to return it to
  950. its old value before your program exits.
  951.  
  952.     If  the  extended  select  bit  is set in the Flags field then the
  953. MaxExtendedSelect  fields  specifies  the maximum number of files that
  954. the user can select.  This is ignored if the extended bit isn't set in
  955. the Flags field.
  956.  
  957.     numlines and numcolumns specify the maximum size that the file box
  958. will  be in characters.  If the system is low on memory, or the screen
  959. is  too  small,  these will be shrunk as necessary.  devcolumns is the
  960. number of columns of characters wide that the device box will be.
  961.  
  962.     The  Flags field can currently contain seven different flags.  The
  963. first  flag,  FRQSHOWINFOM,  specifies  whether  or not '*.info' files
  964. (files  containing information for icons) should be filtered out.  The
  965. default is for them to be filtered.
  966.  
  967.     The  FRQEXTSELECTM  flags  specifies  whether  extended  select is
  968. wanted.   If  you  set this flag then you should probably also set the
  969. MaxExtendedSelect  field.   If  you  don't  then the maximum number of
  970. files  the  user  will be able to select will be 65536, which is a bit
  971. high  for  most  purposes.  Note:  If you use this bit then you _must_
  972. call  PurgeFiles()  with  the  address of your FileRequester structure
  973. after  the  last time you call the file requester, in order to free up
  974. any  memory  used  in  the  extended select structures.  When the user
  975. selects  multiple files, a linked list of the file names selected (not
  976. including the directory name) will appear in the ExtendedSelect field.
  977. The  list  is a linked list of ESStructures.  The directory name which
  978. should  be  prepended  to  all of these names will appear in the array
  979. pointed to by the Dir field.
  980.  
  981.     The  FRQCACHINGM  flag  specifies  whether  or not directories are
  982. cached  from  one  call  to  the next.  This is a very handy features,
  983. especially  for those who lack hard drives.  However, if this features
  984. is  used, you _must_ call the PurgeFiles() routine with the address of
  985. your  FileRequester  structure  after  the last time you call the file
  986. requester, in order to free up any memory used in caching.
  987.  
  988.     As  well  as being a file requester, this routine can be used as a
  989. font requester too.  Just set the FRQGETFONTSM flags to turn it into a
  990. font  requester.   You  should  also  put the name 'fonts:' in the Dir
  991. array.   The file/font requester will return a one or zero for success
  992. or  failure as usual, the font name will be returned in the File array
  993. and  the  font  size  and  style will be returned in the FontYSize and
  994. FontStyle  fields.   Note  that  the font requester allows the user to
  995. change  the  directory  where  the  fonts are read from.  Although you
  996. should  put  'fonts:' there, you should allow for the possibility that
  997. the  user  might  change  the  directory.  They might, perhaps, have a
  998. separate  disk  full  of  fonts.   The simplest way to deal with fonts
  999. coming  from  different  directories,  is  to  set  the PathName field
  1000. instead of the Dir field.  You can then use the string in the PathName
  1001. field  (which  will  contain  the directory and font name) as the font
  1002. name.   If  you  don't  do this, then you have to concatenate the font
  1003. name  and  the  directory  name  yourself.   If  you  use the PathName
  1004. variable  then  it  is quite reasonable to leave the File field blank,
  1005. since  all  the information you need can be obtained from the PathName
  1006. string.
  1007.  
  1008.     The  FRQINFOGADGETM flag specifies whether or not a hide/show info
  1009. gadget should appear on the file requester.  This lets the user toggle
  1010. the  state  of  the  FRQSHOWINFOM flag to decide whether or not to let
  1011. '*.info'  files  show  up.  This is not recommended for most programs,
  1012. since  most  users  have  no  reason  to  look at '*.info' files.  The
  1013. default is to _not_ have this gadget show up.
  1014.  
  1015.     The FRQHIDEWILDSM flag specifies whether or not to have 'show' and
  1016. 'hide'  string  gadgets.   These gadgets let the user use wildcards to
  1017. specify  which  files  should  show  up.  All files are first compared
  1018. against  the 'show' gadget.  If they fail the comparison, they are not
  1019. displayed.  Then they are compared against the 'hide' gadget.  If they
  1020. match  here then they are not displayed.  If the gadgets are empty, no
  1021. comparisons  are done.  Important note:  Even if these gadgets are not
  1022. displayed,  the comparisons are still done on the data which is in the
  1023. Hide  and  Show  fields of the file requester structure.  The standard
  1024. AmigaDOS wildcards (including '#', '?', '|' and '*') are supported.
  1025.  
  1026.     Normally  the  file  requester  appears  centered  under the mouse
  1027. pointer.   If  you would like to specify its opening position you must
  1028. set   the   ABSOLUTEXYM   flag  and  then  put  the  x,y  position  in
  1029. WindowLeftEdge and WindowTopEdge.
  1030.  
  1031.     If you feel that the file requester's cached directories (selected
  1032. by  FRQCACHINGM)  should  be  purged  whenever  the directory has been
  1033. changed,  then  set  FRQCACHEPURGEM  field and the file requester will
  1034. check the dates whenever it is opened.
  1035.  
  1036.     If you feel that the file requester should never cache directories
  1037. unless  it  manages  to  read  in the entire directory before the user
  1038. sends  it  away,  then  set  the FRQNOHALFCACHEM flag.  This flag will
  1039. cause  the file requester to automatically flush any incompletely read
  1040. directories when it exits.
  1041.  
  1042.     If  you  would  like your directories to appear in 'natural' order
  1043. instead of alphabetically sorted, set the FRQNOSORTM flag.
  1044.  
  1045.     If you would like the file requester to appear without a drag bar
  1046. or depth arrangement gadgets, set the FRQNODRAGM flag.
  1047.  
  1048.     If  you  are using the file requester to select a filename to save
  1049. to,  you  should set the FRQSAVINGM flag.  Similarly, if you are using
  1050. the  file  requester to select a filename to load from, you should set
  1051. the  FRQLOADINGM flag.  These flags are not currently used by the file
  1052. requester,  but  they  may  be  used in the future.  They also make it
  1053. easier  for  people who want to personalize the file requester to make
  1054. it behave differently for loading vs.  saving.
  1055.  
  1056.  
  1057.     The  various  color  fields  let  you  specify  the colors of many
  1058. aspects of the file requester.  If they are left as zero then the file
  1059. requester uses various non-zero certain default values for them.
  1060.  
  1061.     The  WindowLeftEdge  and  WindowTopEdge  fields are covered in the
  1062. section on the ABSOLUTEXYM flag.
  1063.  
  1064.     The  FontYSize  and FontStyle fields are covered in the section on
  1065. the FRQGETFONTSM flag.
  1066.  
  1067.     The  ExtendedSelect  field  is  covered  in  the  section  on  the
  1068. FRQEXTSELECTM flag.
  1069.  
  1070.     The  Hide  and  Show  fields  are  covered  in  the section on the
  1071. FRQHIDEWILDSM flag.
  1072.  
  1073. Set this bit if you are selecting a file to save to.
  1074. Set this bit if you are selecting a file(s) to load from.
  1075. These two bits (save and load) aren't currently used for
  1076. anything, but they may be in the future, so you should
  1077. remember to set them.  Also, these bits make it easier if
  1078. somebody wants to customize the file requester for their
  1079. machine.  They can make it behave differently for loading
  1080. vs saving.
  1081.  
  1082.     The  four  BufferPos  and  DispPos  variables  are  copies  of the
  1083. equivalent  variables  from  the four string gadgets.  This is so that
  1084. when  the  file  requester goes away and then is brought up again, the
  1085. cursor in the string gadgets will appear in the same places as before.
  1086. These fields should not need to be touched by the programmer.
  1087.  
  1088.     The  rest  of the fields are private.  Don't go touching them.  We
  1089. guarantee  to  move them around and change their meaning, just to make
  1090. sure  that  nobody tries to use them.  They are largely concerned with
  1091. keeping  track  of  memory  used in directory caching.  This memory is
  1092. freed  with  the  PurgeFiles() routine.  That's all you should need to
  1093. know.
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099. ;--------------------------------------------------------------------
  1100.  
  1101. RealTimeScroll
  1102.  
  1103. NAME
  1104.     RealTimeScroll  -  do the calculations necessary for a responsive,
  1105. pixel resolution, real time scroll routine.
  1106.  
  1107. SYNOPSIS
  1108.     RealTimeScroll(&ScrollStruct);
  1109.                          A0
  1110.  
  1111. FUNCTION
  1112.     Make  the  implementation  of  real time scrolling area easier and
  1113. make the real time scrolling area more responsive to the user by doing
  1114. pixel resolution scrolling and by checking the current position of the
  1115. scroll  bar  in mid scroll.  This routine calculates how far to scroll
  1116. each  time  and calculates which lines of text, graphics etc.  need to
  1117. be redrawn to fill in the empty area.
  1118.  
  1119. INPUTS
  1120.     &ScrollStruct - pointer to an initialized scroll structure.
  1121.  
  1122. RESULT
  1123.     This routine returns no result code.
  1124.  
  1125. BUGS
  1126.     None known
  1127.  
  1128. SEE ALSO
  1129.     n/a
  1130.  
  1131.  
  1132.     It is relatively easy to implement a real time scrolling area, but
  1133. the most obvious implementations suffer from a lack of responsiveness.
  1134. Typically  the  routines  look  at  where the scroll bar is, calculate
  1135. where  to  scroll  to,  scroll  there  in  several  jumps  to make the
  1136. scrolling  look smooth, and the examine the scroll bar again to see if
  1137. it  has  moved.  This means that there are periods, perhaps annoyingly
  1138. long,  where  the  program may be scrolling in one direction while the
  1139. scroll  bar is being dragged in another.  The answer is to examine the
  1140. scroll  bar  to  find out the desired location, scroll partway towards
  1141. the  destination and then recheck the scroll bar's location.  This can
  1142. greatly  increase  the  responsiveness,  since the program is checking
  1143. after  every  ScrollRaster()  call,  instead of after a dozen or more.
  1144. However,  the  calculations,  especially  of  which  lines  need to be
  1145. refreshed  and  where, get somewhat more complicated.  This routine is
  1146. designed  to  simplify this situation by taking care of as many of the
  1147. messy details as possible.
  1148.  
  1149.     First   you   must   initialize   the   scroll   structure.    The
  1150. TopEntryNumber, NumEntries and NumLines fields describe where the data
  1151. is  currently.   NumEntries  is  the number of lines of data in total,
  1152. NumLines  is  the number of lines that are visible, and TopEntryNumber
  1153. is the line number of the first line visible (it therefore ranges from
  1154. zero to NumEntries - 1).
  1155.  
  1156.     LineSpacing  is  the  number of pixels high that each line of data
  1157. is.   For  text  this  will  typically be eight or nine (for eighty or
  1158. sixty  column  topaz).   This  can  be  set  to  one  if  your data is
  1159. continuous (as in the case of some graphics).
  1160.  
  1161.     PropGadget  is a pointer to the prop gadget which is being used to
  1162. control this scroll area.
  1163.  
  1164.     RedrawAll  is  a  pointer  to  a  function that you must supply to
  1165. redraw the entire visible window.  This routine is called whenever the
  1166. user  gets  so far ahead of the scroll routine that scrolling to where
  1167. the  users  wants  to  be  would  take  to  long.  Before calling this
  1168. routine,  the  ScrollStruct that was passed to this routine is updated
  1169. with  the  desired TopEntryNumber so that your routine will know which
  1170. data to redraw.
  1171.  
  1172.     ReadMore is an optional routine that will usually not be used.  It
  1173. is  used  if more data is being added while the scrolling is going on.
  1174. This  is  used,  for  instance,  by  the  FileRequest in the requester
  1175. library, to continue attempting to read the directoy while the user is
  1176. scrolling.   Leave  this set to zero if you don't need it.  It is only
  1177. called  when no scrolling is being done, but the user has not released
  1178. the scroll bar.
  1179.  
  1180.     ScrollAndDraw  is the most important routine.  This routine, which
  1181. you  must  supply,  is called whenever the data must be scrolled.  The
  1182. actual  scrolling  and  redrawing of the data is done by this routine,
  1183. but because the scroll amount, the lines to be drawn and the number of
  1184. lines  to  be  drawn are passed to this routine, the routine is fairly
  1185. simple.  Four parameters are passed to this routine:
  1186.  
  1187. ScrollAndDraw(firstlinenum, firstliney, scrollamount, numlines);
  1188.  
  1189.     All  four parameters are passed as longs, both on the stack and in
  1190. D0-D3,  so  that  the  routine  can  easily  be written in either C or
  1191. assembler.
  1192.  
  1193.     When the ScrollAndDraw, ReadMore or RedrawAll routines are called,
  1194. A4,  A5  and  A6  all  contain  the  same  values  they contained when
  1195. RealTimeScroll  was  called.   This allows programs written in C using
  1196. the  small  data  model  to be able to access their data properly from
  1197. these  routines without any special work.  All other registers (except
  1198. those that are used to pass parameters in) could contain anything.
  1199.  
  1200.  
  1201.  
  1202.  
  1203. ;--------------------------------------------------------------------
  1204.  
  1205.  
  1206.  
  1207. TextRequest
  1208.  
  1209. NAME
  1210.     TextRequest  - bring up a text requester with one to three gadgets
  1211. and get a response.
  1212.  
  1213. SYNOPSIS
  1214.     result = TextRequest(&TRStructure);
  1215.       D0                      A0
  1216.  
  1217. FUNCTION
  1218.     Bring  up  a requester (actually a window) containing a message to
  1219. the  user  and  give  him  a  choice  of  from  one to three different
  1220. responses.   The  window  automatically  sizes  to  fit  the  text and
  1221. printf() style formatting can be used by TextRequest() to generate the
  1222. message to the user.
  1223.  
  1224. INPUTS
  1225.     &TRStructure - pointer to an initialized text requester structure.
  1226.  
  1227. RESULT
  1228.     Returns  either  zero,  one  or two, depending on which gadget the
  1229. user  clicks  on.   All  of  the  gadgets  are  optional,  so that the
  1230. requester  can  be  used  to  bring up requesters that give the user a
  1231. message,  without demanding an answer, by having only a single gadget.
  1232. The  gadget  in  the  lower  right  hand  corner (the negative gadget)
  1233. returns a zero, the gadget in the lower left hand corner (the positive
  1234. gadget)  returns a one and the gadget in the middle returns a two.  If
  1235. none  of these three gadgets are requested, a close gadget is attached
  1236. to the window and it returns a zero.
  1237.  
  1238. BUGS
  1239.     If  any  line  of  the  text  to  be printed is too long, then the
  1240. requester  will  attempt  to open up an impossibly large window, which
  1241. will fail and the requester will return a zero.
  1242.     The  buffer used for formatting the text is 5000 bytes long, so no
  1243. messages can be longer than this.
  1244.  
  1245. SEE ALSO
  1246.     SimpleRequest
  1247.     TwoGadRequest
  1248.  
  1249.  
  1250.     The  purpose  of  this  routine  is  to  make  it as easy to print
  1251. formatted  messages  in  intuitionized window with gadgets as it is to
  1252. print  them  on the CLI screen.  For maximum ease of use, at a loss of
  1253. flexibility,  please see the functions SimpleRequest and TwoGadRequest
  1254. which  are  simply  glue  code functions to make calling TextRequest a
  1255. trivial matter.
  1256.  
  1257.     If  you want the text requester to appear on a custom screen, then
  1258. you must set the pr_WindowPtr field in your process structure to point
  1259. at  one  of the windows on your screen (this should be done anyway, so
  1260. that  DOS  requesters  appear  on  your custom screen).  This field is
  1261. looked at by all functions in the requester library so this way is the
  1262. simplest method.  Important note:  It is VERY important that you reset
  1263. the  pr_WindowPtr field back to its original value before your program
  1264. exits.  If you don't, the next program run may try to open a requester
  1265. window on a now closed screen.
  1266.  
  1267.     The  structure  whose  address  is  passed to this routine must be
  1268. initialized first.
  1269.  
  1270.     The  Text field is initialized with the body of the text you would
  1271. like  displayed.  This text can contain both printf() style formatting
  1272. and  end  of  line characters ('\n' in C, ascii 10 in assembler).  The
  1273. printf()  style formatting, is expanded out into the final text string
  1274. using  the  parameter  list which is pointed to by the Controls field.
  1275. Line  feeds  are  used, as usual, to specify a new line, thus allowing
  1276. very  long  and  complex  messages  to  be  displayed.   The  are some
  1277. limitations  on  the  types  of  printf() formatting that can be used.
  1278. Since the RawDoFmt() function of the ROM is used to do the formatting,
  1279. only   functions   supported   by   it  can  be  used.   For  complete
  1280. documentation,  see  the documentation of the RawDoFmt() command.  The
  1281. main  things  to be aware of is that floating point numbers can not be
  1282. printed,  and,  if  you  are using a compiler that uses thirty-two bit
  1283. ints  then  we  will  have to specify '%ld' to print an int, since the
  1284. RawDoFmt command assumes an int size of sixteen bits.
  1285.  
  1286.     The Controls field points to a list of parameters, one for each of
  1287. the  '%'  parameters in the Text field.  Normally these will be pushed
  1288. on  to the stack and the stack pointer copied into the Controls field.
  1289. The first parameter used (the first one to occur in the string) should
  1290. be  at  the beginning of the list, that is, at the lowest address, the
  1291. one pointed at by the Controls parameter.
  1292.  
  1293.     The Window field can be used to specify what screen you would like
  1294. the requester to appear on.  This field is usually not necessary since
  1295. the same information can be conveyed in the pr_WindowPtr field of your
  1296. process  structure.   However  this  field  was  left  in  so that the
  1297. TextRequest  function  could  be  called  from  a  task (which lacks a
  1298. process  structure and therefore a pr_WindowPtr field).  If this field
  1299. is  non-zero or if the calling program is a task then this field takes
  1300. precedence over the pr_WindowPtr field.
  1301.  
  1302.     MiddleText,  PositiveText  and NegativeText are the pieces of text
  1303. used  for  the  three gadgets.  These three gadgets, when present, are
  1304. placed   in  the  middle,  the  left  and  the  right  of  the  window
  1305. respectively.   All  three  gadgets are placed along the bottom of the
  1306. window.   All of the gadgets are optional.  If a gadget is not wanted,
  1307. the  text  pointer  should be set to zero.  The values returned if the
  1308. user  clicks  on these gadgets are two, one or zero, respectively.  If
  1309. none  of  the gadgets are present (if all of the text fields are zero)
  1310. then  a  standard  CLOSEWINDOW gadget is attached to the window.  This
  1311. gadget returns a zero.
  1312.  
  1313.     The  requester  attempt  to  appear so that the negative gadget is
  1314. underneath  the  mouse pointer.  If the negative gadget is not present
  1315. it will attempt to appear so that a different gadget is underneath the
  1316. mouse  pointer.   This is to make it as convenient as possible for the
  1317. user  to  respond  to,  and  especially  to respond negatively to, the
  1318. requester.
  1319.  
  1320.     In  addition  to  responding  to  the  requester  with  the mouse,
  1321. keyboard  shortcuts are available.  The user can type ESC, 'N', 'Q' or
  1322. 'B'  as  a  shortcut to clicking on the negative gadget.  The user can
  1323. type  'Y'  or 'V' as a shortcut to clicking on the positive gadget and
  1324. can type 'M' as a shortcut to clicking on the middle gadget.
  1325.  
  1326.     The  Title  field  of  the structure should either point to a null
  1327. terminated  string  to  be  used in the windows title bar or should be
  1328. null.
  1329.  
  1330.     The  KeyMask  field  is  used  to  regulate  the  use  of keyboard
  1331. shortcuts.  The qualifier field of all keyboard messages is ANDed with
  1332. this  field,  and  the  keypress  is  ignored  if  the result is zero.
  1333. Therefore,  to enable all keypresses to be used as keyboard shortcuts,
  1334. initialize  this  field to $FFFF.  To turn off the keyboard shortcuts,
  1335. initialize  this  field to 0.  To force the user to hold down the left
  1336. or right amiga key, initialize this field to AMIGAKEYS.
  1337.  
  1338.     The  textcolor,  detailcolor  and  blockcolor  fields  can be left
  1339. unitialized (ie; set to zero) if you wish, in which case the requester
  1340. will  use  the  default values of one, zero and one respectively.  The
  1341. textcolor  field  is used for the color of the actual text message and
  1342. the detail and block color fields are simple copied into the fields of
  1343. the same name in the new window structure.
  1344.  
  1345. ;--------------------------------------------------------------------
  1346.  
  1347.  
  1348. SimpleRequest
  1349.  
  1350. NAME
  1351.     SimpleRequest - bring up a text requester and wait for the user to
  1352. acknowledge it.
  1353.  
  1354. SYNPOSIS
  1355.     SimpleRequest(string, parameterlist, , ,)
  1356.                     A0        A1
  1357.  
  1358. FUNCTION
  1359.     Bring  up  a requester (actually a window) containing a message to
  1360. the  user  and  wait  for  the  user  to  acknowledge  it.  The window
  1361. automatically  sizes to fit the text and printf() style formatting can
  1362. be used by TextRequest() to generate the message to the user.
  1363.  
  1364. INPUTS
  1365.     string  -  a  null  terminated  string,  containing printf() style
  1366. formatting commands if desired.
  1367.     parameterlist - the parameters corresponding to the printf() style
  1368. formatting  commands  in  the string.  In C these are listed after the
  1369. control  string,  exactly as with printf().  In assembler, the address
  1370. of the list of parameters is put in A1.
  1371.  
  1372. RESULT
  1373.     No result code is returned.
  1374.  
  1375. BUGS
  1376.     See TextRequest
  1377.  
  1378. SEE ALSO
  1379.     TextRequest
  1380.     TwoGadRequest
  1381.  
  1382.  
  1383.     This  function was designed to make it as easy to give messages to
  1384. the  user  and await acknowledgment in an intuition style requester as
  1385. it  is  using  printf() and getc().  Simply replace almost any call to
  1386. printf()  with a call to SimpleRequest and a requester will appear and
  1387. not  disappear until the user acknowledges it (either with a keystroke
  1388. or with the mouse).
  1389.  
  1390.     Example:
  1391.         SimpleRequest("There  have  %d  changes  made  to this file.",
  1392.                         numchanges);
  1393.  
  1394.     Please  see  the  TextRequest  documentation for further important
  1395. details.   This  routine  is simply a few lines of assembler glue code
  1396. for  the TextRequest routine.  The TextRequest routine is a little bit
  1397. more   complicated   to   use,  but  it  allows  correspondingly  more
  1398. flexibility.   It  is  fairly  simple to modify the glue code to allow
  1399. still more high level entry points to the TextRequest routine.
  1400.  
  1401.  
  1402.     This  is  a  complete  program that makes use of the SimpleRequest
  1403. function  from  assembler,  and  demonstrates a few of the features of
  1404. Format (which is used by SimpleRequest).
  1405.  
  1406. ;--------------------------------------------------------------------
  1407. ;-----CUT HERE---------------CUT HERE--------------------------------
  1408. ;--------------------------------------------------------------------
  1409.  
  1410.     INCLUDE "libraries/reqbase.i"
  1411.  
  1412.     public  SimpleRequest
  1413.     public  _ReqBase,_main
  1414.  
  1415. ;--------------------------------------------------------
  1416. ; This file should be linked with reqglue.o, for the SimpleRequest
  1417. ;function.
  1418. ;--------------------------------------------------------
  1419.  
  1420. SYS MACRO
  1421.     XREF    _LVO\1
  1422.     JSR _LVO\1(A6)
  1423.     ENDM
  1424.  
  1425. ;--------------------------------------------------------
  1426.  
  1427.  
  1428. _main
  1429.     OpenReq
  1430. mystart
  1431.  
  1432.     MOVE.L  A6,A5
  1433.     MOVE.L  A6,_ReqBase
  1434.  
  1435.  
  1436.     PEA     string
  1437.     MOVE.L  #$C0FFEE,-(SP)
  1438.     MOVE.W  #$1CE,-(SP)
  1439.     MOVE.W  #'B',-(SP)
  1440.     MOVE.L  #-12345,-(SP)
  1441.     MOVE.L  SP,A1
  1442.     LEA     Text,A0
  1443.     JSR     SimpleRequest
  1444.  
  1445.     LEA     16(SP),SP
  1446.  
  1447.     MOVE.L  A5,A1
  1448.     MOVE.L  4,A6
  1449.     SYS     CloseLibrary
  1450.  
  1451.     MOVEQ   #0,D0
  1452.     RTS
  1453. string
  1454.     DC.B    "This is a string.",0
  1455. Text
  1456.     DC.B    "A long (signed) decimal is: %ld,",10
  1457.     DC.B    "a character is: %c,",10
  1458.     DC.B    "a 16 bit hex val might be: %x, ",10
  1459.     DC.B    "a register-style format 32 bit hex: $%08lx,",10
  1460.     DC.B    "and a string might read: `%s'.",0
  1461.  
  1462.     dseg
  1463.  
  1464. _ReqBase    DC.L    0   ;The SimpleRequest function in the glue code
  1465.                         ;needs this variable.
  1466.  
  1467.     END
  1468.  
  1469. ;--------------------------------------------------------------------
  1470. ;-----CUT HERE---------------CUT HERE--------------------------------
  1471. ;--------------------------------------------------------------------
  1472.  
  1473.  
  1474.  
  1475.  
  1476. ;--------------------------------------------------------------------
  1477.  
  1478.  
  1479.  
  1480. TwoGadRequest
  1481.  
  1482. NAME
  1483.     TwoGadRequest - bring up a text requester and wait for the user to
  1484. acknowledge it.
  1485.  
  1486. SYNPOSIS
  1487.     result = TwoGadRequest(string, parameterlist, , ,)
  1488.                              A0        A1
  1489.  
  1490. FUNCTION
  1491.     Bring  up  a requester (actually a window) containing a message to
  1492. the user and wait for the user to click on either the OK or the CANCEL
  1493. gadget.   The  window automatically sizes to fit the text and printf()
  1494. style  formatting can be used by TextRequest() to generate the message
  1495. to the user.
  1496.  
  1497. INPUTS
  1498.     string  -  a  null  terminated  string,  containing printf() style
  1499. formatting commands if desired.
  1500.     parameterlist - the parameters corresponding to the printf() style
  1501. formatting  commands  in  the string.  In C these are listed after the
  1502. control  string,  exactly as with printf().  In assembler, the address
  1503. of the list of parameters is put in A1.
  1504.  
  1505. RESULT
  1506.     Either  one  or  zero  is  returned, depending on whether the user
  1507. selected, respectively, the OK or the CANCEL gadget.
  1508.  
  1509. BUGS
  1510.     See TextRequest
  1511.  
  1512. SEE ALSO
  1513.     TextRequest
  1514.     SimpleRequest
  1515.  
  1516.  
  1517.     This  function was designed to make it as easy to give messages to
  1518. the  user  and get a response in an intuition style requester as it is
  1519. using printf() and getc().  Simply replace almost any call to printf()
  1520. with  a  call  to  SimpleRequest  and  a requester will appear and not
  1521. disappear  until  the  user responds to it (either with a keystroke or
  1522. with the mouse).
  1523.  
  1524.     Example:
  1525.         if (TwoGadRequest("There have %d changes made to this file.\n"
  1526.                           "O.K. to continue?",
  1527.                           numchanges))
  1528.             exit(10);
  1529.  
  1530.     Please  see  the  TextRequest  documentation for further important
  1531. details.   This  routine  is simply a few lines of assembler glue code
  1532. for  the TextRequest routine.  The TextRequest routine is a little bit
  1533. more   complicated   to   use,  but  it  allows  correspondingly  more
  1534. flexibility.   It  is  fairly  simple to modify the glue code to allow
  1535. still more high level entry points to the TextRequest routine.
  1536.  
  1537.  
  1538.  
  1539. -------------------------------------------------------------------
  1540. NAME
  1541.     GetString
  1542.  
  1543. BOOL = GetString(buffer, title, window, visiblechars, maxchars)
  1544. D0                 A0      A1     A2        D0          D1
  1545.  
  1546. DESCRIPTION
  1547.     This  routine allows you to bring up a nice intuition style string
  1548. requester  in  its  own window and get a single line of input from the
  1549. user in just a one line function call.
  1550.  
  1551.     buffer  points  to  the  a buffer containing the string which will
  1552. appear  when  the string gadget first appears and it is also where the
  1553. result will be put, if this routine returns TRUE.
  1554.     Title  is  a pointer to a null terminated string that will be used
  1555. for the window title.
  1556.     Window  can  be  used  to  specify  what screen you would like the
  1557. requester  to  appear on.  You simply put a window pointer in it (or a
  1558. zero if you want the requester to appear on the workbench screen).  If
  1559. you have already set your pr_WindowPtr then you can simply pass a zero
  1560. for the window pointer and the pr_WindowPtr value will be used.
  1561.     visiblechars  specifies  how  many  characters  should actually be
  1562. visible at one time.
  1563.     maxchars   specifies   how  long  the  buffer  is,  including  the
  1564. terminating zero.
  1565.  
  1566. RETURNS
  1567.     This  routine returns true or false, depending on whether the user
  1568. clicked  on  the  cancel  gadget  (FALSE)  or clicked on the OK gadget
  1569. (TRUE)  or clicked on the close window gadget (FALSE) or hit return in
  1570. the string gadget (TRUE).
  1571.  
  1572. BUGS
  1573.     None known.
  1574.  
  1575.  
  1576.  
  1577. -------------------------------------------------------------------
  1578. NAME
  1579.     GetLong
  1580.  
  1581. BOOL = GetLong(&GetLongStruct)
  1582. D0                   A0
  1583.  
  1584. DESCRIPTION
  1585.     This  routine allows you to bring up a nice intuition style string
  1586. requester  in  its  own  window and get a single signed thirty-two bit
  1587. number  from the user in just a one line function call (although a few
  1588. fields in the structure must be initialized first).
  1589.  
  1590.     The  GetLongStruct  contains  fields  for  letting you specify the
  1591. title  bar  message,  the  default  value  that  should  appear in the
  1592. requester  and  the maximum and minimum values that the routine should
  1593. allow  to  be  entered.   If  the  routine  returns  TRUE  (indicating
  1594. successful  entry  of  a  number)  then  the result is returned in the
  1595. result field of the structure.
  1596.     The window field can be used to specify what screen you would like
  1597. the requester to appear on.  You simply put a window pointer in it (or
  1598. a  zero  if you want the requester to appear on the workbench screen).
  1599. If  you  have  already set your pr_WindowPtr then you can simply leave
  1600. the window field zeor and the pr_WindowPtr value will be used.
  1601.  
  1602. RETURNS
  1603.     This  routine  returns  TRUE  or  FALSE  (1 or 0) in D0 to specify
  1604. whether  or  not  the  user  successfully  entered  a number.  If this
  1605. routine  returns TRUE then you can find the result in the result field
  1606. of the GetLongStruct whose address you passed to GetLong.
  1607.  
  1608.  
  1609.  
  1610. -------------------------------------------------------------------
  1611. RawKeyToAscii
  1612.  
  1613. SYNOPSIS
  1614.  
  1615.  key = RawKeyToAscii(Code,Qualifier,IAddress)
  1616.  D0                   D0     D1        A0
  1617.  
  1618.  UWORD  Code,Qualifier;
  1619.  APTR   IAddress;
  1620.  
  1621. FUNCTION
  1622.  
  1623.     Have you ever wanted to have both RAW and COOKED keys?  You can do
  1624. it by checking the keys for whatever raw keys you want, and then using
  1625. the  console.device's RawKeyConvert routine, except that it's a hassle
  1626. to start mucking about with the device.
  1627.  
  1628.     Well, here you go!  A nice, clean way of converting from a raw key
  1629. to  a  cooked  key,  in a single call!  All you have to do is pass the
  1630. code  and  qualifier  from  your  intuimessage, and the address of the
  1631. message  itself, and you will get back the ASCII value of the key that
  1632. was  hit.  This does, in fact, use the console.device's RawKeyConvert,
  1633. so that if you have a different keymap set, it will be used.
  1634.  
  1635. EXAMPLE
  1636.  
  1637.  
  1638. struct IntuiMessage *im;
  1639.  
  1640.     key = RawKeyToAscii(im->Code,im->Qualifier,im->IAddress);
  1641.  
  1642.